package entity;


import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


import sql_class.Greade;
import util.DBUtil;
import dao.GradeDao;

public class LookGrade implements GradeDao {

	@Override
	public  List<Greade> getAll() {
		List<Greade> list = new ArrayList<Greade>();
		String sql = "select * from grade";
		PreparedStatement st = null;
		ResultSet rs = null;
		Connection con = DBUtil.open();
		Greade gd = null;
		try {
			st = con.prepareStatement(sql);		
			rs = st.executeQuery();
			while (rs.next()){	
			    gd = new Greade();
				gd.setId(rs.getInt("id"));
				gd.setGname(rs.getString("gname"));
				list.add(gd);		
			}
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
		
		
	}
}